package qinyi365;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Map;


public class UpdataThread extends Thread{
	 Connection conn = null;
	List<Map<String,String>> list;
	boolean overflg = false;
	public UpdataThread(List<Map<String,String>> l, Connection conn )
	{
		this.list = l;
		this.conn = conn;
	}
	public void run() {
		//GetCoord gc = new GetCoord();
		for(int i=0;i<list.size();i++)
		{
			String address = list.get(i).get("address");
			//String city = list.get(i).get("city");
			String receiverid = list.get(i).get("receiverid");
			//Point p = gc.getC(address, city);
			AddressLatLngUtil util = new AddressLatLngUtil();
			Point p = util.getPointFromAddress(address);
		if(p != null)
		{
			//System.out.println(p.lng + " " + p.lat);
			try {
				Statement stmt = conn.createStatement();
				String sql = "update qy_import_data set x = " + p.lng + ",y = "+ p.lat +" where receiver_id = "+receiverid;
				stmt.execute(sql);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		else
		{
			System.out.println("null  " + address);
		}
		}
		try {
			conn.commit();
			conn.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		overflg = true;
	}
}
